<!--
 * @Descripttion:
 * @version:
 * @Author:
 * @Date: 2019-09-28 09:30:03
 -->
<template>

  <MetaDataTypeView :treeData="treeData"
                    :tableData="tableData"
                    :Loading="Loading"
                    :page="page"
                    @handleNodeClick="handleNodeClick"
                    @changePage="changePage"
                    @sizeChange="sizeChange"></MetaDataTypeView>
</template>
<script>
import MetaDataTypeView from './metaDataTypeView'
import metadataTypeApi from '@/httpUtils/ExternalManagement/metadataType'
export default {
  name: 'metadataTypeLogic',
  components: {
    MetaDataTypeView
  },
  data () {
    return {
      treeData: [],
      tableData: [],
      page: {
        pageNum: 1,
        pageSize: 5,
        total: 10,
        catalogId: '',
      },
      Loading: false,
    }
  },
  watch: {
    page: {
      handler (newName, oldName) {
        metadataTypeApi.queryMetaDataType(this.page).then(res => {
          this.tableData = res.data.data.list
          this.page.total = res.data.data.total
          this.page.pageNum = res.data.data.pageNum
          this.page.pageSize = res.data.data.pageSize
        })
      },
      immediate: true,
      deep: true
    }
  },
  mounted () {
    //  获取元数据类型目录树
    metadataTypeApi.findCatalog().then(res => {
      res.data.data = this.IterationDelateMenuChildren(res.data.data)
      this.treeData = res.data.data
    })
  },
  methods: {
    // 点击节点事件获取表格数据
    handleNodeClick (data) {
      console.log(data) //  点击tree节点的信息
      this.page.catalogId = data.id
    },
    //  点击分页按钮
    changePage (pageNum) {
      console.log(pageNum)
      this.page.pageNum = pageNum
    },
    //  切换页数
    sizeChange (pageSize) {
      console.log(pageSize)
      this.page.pageSize = pageSize
    },
  }
}
</script>
